import chardet
str1 = b"Hello, world!"
str2 = "华硕品质，坚若磐石。".encode("gbk")
str3 = "车到山前必有路。".encode("utf-8")
str4 = "最新の主要ニュース".encode("euc-jp")
# ---confidence检测概率--language检测语言--
print(chardet.detect(str1))
print(chardet.detect(str2))
print(chardet.detect(str3)["encoding"])
print(chardet.detect(str4))


